import React, {Component} from 'react'
import {Popconfirm, Icon} from 'antd'
import propTypes from 'prop-types'

class PopConfirm extends Component {
  render() {
    const {title, onConfirm, placement} = this.props

    return (
      <Popconfirm
        placement={placement}
        title={title}
        onConfirm={onConfirm}
        okText="确定"
        cancelText="取消"
      >
        {
          this.props.children
        }
      </Popconfirm>
    )
  }
}

PopConfirm.propTypes = {
  title: propTypes.string,
  onConfirm: propTypes.func,
  placement: propTypes.oneOf(['left', 'right', 'top', 'bottom', 'bottomRight', 'topLeft', 'topRight', 'bottomLeft', 'leftTop', 'leftBottom', 'rightTop', 'rightBottom']),
  icon: propTypes.element
}

PopConfirm.defaultProps = {
  title: '确定删除？',
  onConfirm: () => {},
  placement: 'right',
  icon: <Icon type="question-circle-o" style={{ color: 'red' }} />
}

export {PopConfirm}
